package com.base.library.view.systemPhotoAlbum;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.GridView;

import com.base.library.R;
import com.base.library.activity.BaseActivity;
import com.base.library.view.upPhotoView.UpPhotoView;

import java.io.Serializable;
import java.util.List;

public class ShowImageActivity extends BaseActivity {
    private GridView mGridView;
    private List<String> list;
    private ChildAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.show_image_activity);
        setTitleName("选择图片");
        mGridView = (GridView) findViewById(R.id.child_grid);
        list = getIntent().getStringArrayListExtra("data");
        adapter = new ChildAdapter(this, list, mGridView);
        mGridView.setAdapter(adapter);
        adapter.setOnClickItem(new ChildAdapter.onClickItem() {
            @Override
            public void click(int position) {
                Intent intent = new Intent(ShowImageActivity.this, PhotoInfoActivity.class);
                intent.putExtra("path", (Serializable) list);
                intent.putExtra("position", position);
                startActivity(intent);
            }
        });
        setRightInit("完成", new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                setResult(620);
                if (UpPhotoView.getOnPhotoList() != null) {
                    UpPhotoView.getOnPhotoList().selectPhoto(adapter.selected);
                }
                finish();
            }
        });
    }
}
